The controls provide client-side objects which can be used to work with them in Javascript.
To access the Javascript object, add
var inline = <%= RapidSpellWInline1.ClientSideObject %>;
to the page inside a Javascript function (note, don't allow this to be called as the page loads, since it will probably appear before the control has rendered and therefore not be valid yet). This will set your 'inline' variable to the object instance, which can then be used to call the following;
textBoxID - the ID of the text box being worked with OnSpellButtonClicked() - starts the spell check tbInterface - holds an instance of the TextComponentInterface, which provides getText()/setText() methods to work with the text in the text box buttonID - the ID of the button that the spell checker rendered getParameterValue(parameterName) - gets the value of the spell check parameter setParameterValue(parameterName, value) - gets the value of the spell check parameter
- parameter names match exactly the control's property names (that control the spell check behavior), eg; UserDictionaryFile, DictFile, SuggestionsMethod, LanguageParser, SeparateHyphenWords, V2Parser, SuggestSplitWords, IncludeUserDictionaryInSuggestions, WarnDuplicates, IgnoreWordsWithDigits, CheckCompoundWords, LookIntoHyphenatedText, IgnoreXML, IgnoreCapitalizedWords, ConsiderationRange, IgnoreURLsAndEmailAddresses, AllowMixedCase. showNoSpellingErrorsMesg - true/false; whether to show the 'no errors' message showAddMenuItem - true/false; whether to show the add menu item noSpellingErrorsText - text shown when no errors are found enterEditModeWhenNoErrors - true/false; whether to auto switch back to edit mode when in static mode and no errors are left. noSuggestionsText - text used in 'no suggestions' menu item ignoreAllText - text used in 'ignore all' menu item. showChangeAllItem - true/false; whether to show the 'change all' menu item changeAllText - text used in 'change all' menu item (see above) addText - text used in 'add' menu item editText - text used in 'edit' menu item removeDuplicateText - text used in 'remove duplicate word' menu item buttonTextSpellChecking - button text during spell checking activation buttonTextSpellMode - button text during spell mode buttonText - button text during edit mode changeButtonTextWithState - true/false; whether to change the button state/text when spell checking responseTimeout - seconds before the spell check request times out responseTimeoutMessage - message shown to user after timeout doubleClickSwitchesMode - whether double clicking switches mode during static check ignoreXML - whether XML/HTML is to be ignored
To access the Javascript object, add
var launcher = <%= RapidSpellWebLauncher1.ClientSideObject %>;
to the page inside a Javascript function (note, don't allow this to be called as the page loads, since it will probably appear before the control has rendered and therefore not be valid yet). This will set your 'launcher' variable to the object instance, which can then be used to call the following;
OnSpellButtonClicked() - starts the spell check tbInterface - holds an instance of the TextComponentInterface, which provides getText()/setText() methods to work with the text in the text box getParameterValue(parameterName) - gets the value of the spell check parameter setParameterValue(parameterName, value) - gets the value of the spell check parameter - parameter names match exactly the control's property names (that control the spell check behavior), eg; UserDictionaryFile, DictFile, SuggestionsMethod, LanguageParser, SeparateHyphenWords, V2Parser, SuggestSplitWords, IncludeUserDictionaryInSuggestions, WarnDuplicates, IgnoreWordsWithDigits, CheckCompoundWords, LookIntoHyphenatedText, IgnoreXML, IgnoreCapitalizedWords, ConsiderationRange, IgnoreURLsAndEmailAddresses, AllowMixedCase.
To access the Javascript object, add
var inlineTB = <%= RapidSpellWInlineTextBox1.ClientSideObject %>;
to the page inside a Javascript function (note, don't allow this to be called as the page loads, since it will probably appear before the control has rendered and therefore not be valid yet). This will set your 'inlineTB' variable to the object instance, which can then be used to call the following;
GetText() - gets the text in the textbox SetText(text) - sets the text in the textbox OnKeyDown - function to be called on event (see example below) OnKeyUp - function to be called on event (see example below) OnKeyPress - function to be called on event (see example below) OnCorrection - function to be called on event (see example below) OnPaste - function to be called on event (see example below) OnContextMenu - function to be called on event (see example below) OnBlur - function to be called on event (see example below) OnFocus - function to be called on event (see example below) OnMouseDown - function to be called on event (see example below) OnMouseUp - function to be called on event (see example below) GetNumberOfErrors() - gets the number of errors highlighted in the textbox Focus() - gives user focus to the text box SetDisabled(disabled) - disables the textbox Select() - selects the entire text
This example works with RapidSpellWInline and RapidSpellWInlineTextBox to show all text box events, start the spell checker from a JS call, block specified characters from being typed and focus on demand.
<%@ Page language="c#" AutoEventWireup="false" %> <%@ Register TagPrefix="rapidspellweb" Namespace="Keyoti.RapidSpell" Assembly="Keyoti.RapidSpellWeb.ASP.NETv2" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <script type="text/javascript"> var inline; var tb1; var ot1; function RunSpell(){ inline.OnSpellButtonClicked(); } //called automatically when the textboxes have loaded. function RS_OnTextBoxesInitialized(){ tb1 = <%= RapidSpellWInlineTextBox1.ClientSideObject %>; ot1 = document.getElementById('t1'); inline = <%= RapidSpellWInline1.ClientSideObject %>; update(); tb1.OnKeyDown = OnEvent; tb1.OnKeyUp = OnEvent; tb1.OnKeyPress = OnEvent; tb1.OnCorrection = OnEvent; tb1.OnPaste = OnEvent; tb1.OnContextMenu = OnEvent; tb1.OnBlur = OnEvent; tb1.OnFocus = OnEvent; tb1.OnMouseDown = OnEvent; tb1.OnMouseUp = OnEvent; } function dofocus(){ tb1.Focus(); } function update(){ ot1.value = tb1.GetText(); } function resetText(){ tb1.SetText("The text has been reset."); } function OnEvent(source, e){ if(e.type=="keypress"){ var chr; if(e.charCode)//MOZ chr = e.charCode; else chr = e.keyCode; var blockChar = document.getElementById('blockChar').value; if(blockChar == String.fromCharCode( chr ) ){ e.returnValue = false; if(e.preventDefault){ e.preventDefault(); e.cancelBubble = true; } } } if(e!=null){ ot1.value = e.type+"\r\n" + ot1.value; var mesg; if(e.type=='correction'){ if( e.replacement != e.errorWord) mesg = e.errorWord+" was changed to "+e.replacement+", "; else mesg = e.errorWord+" was ignored, "; ot1.value = mesg+ "errors remaining = "+tb1.GetNumberOfErrors()+"\r\n" + ot1.value; } } } </script> </HEAD> <body> <form runat="server"> <RAPIDSPELLWEB:RAPIDSPELLWINLINETEXTBOX id="RapidSpellWInlineTextBox1" runat="server" ClientFilesFolder="/Keyoti_RapidSpell_Web_Common/" Font-Size="18pt" Font-Bold="True" Width="605px" Height="423px" TextMode="MultiLine">Thiss is a RapidSpellWInlineTextBox</RAPIDSPELLWEB:RAPIDSPELLWINLINETEXTBOX> <br> <input onclick="update()" type="button" value="Send text box text to text area"> <br> <input onclick="resetText()" type="button" value="Reset text box text"> <br> <input onclick="dofocus()" type="button" value="Get focus"> <br> Block this character -> <input id="blockChar" type="text" size="4" value="+"> <br> <input onclick="RunSpell()" type="button" value="Start spell"> <br> <br> <textarea id="t1" rows="10" cols="40"></textarea> <br> <rapidspellweb:rapidspellwinline id="RapidSpellWInline1" runat="server" RapidSpellWInlineHelperPage="rswihelper.aspx" TextComponentID="RapidSpellWInlineTextBox1" ButtonText="Inline Ctrl"> <Button BorderWidth="" BackColor="" ForeColor="" Height="" Width="" Enabled="True" BorderColor="" CssClass="" type="button" value="Inline Ctrl" ID="RapidSpellWInline1_RapidSpellWInline1__ctl0"></Button> </rapidspellweb:rapidspellwinline> </form> </body> </HTML>